import { baseURL, token } from "./axios.js";

export const createThumbnail = function (item, hasBaseUrl = true) {
	const { path, hash } = item;
	if (process.env.NODE_ENV !== "production") {
		//return baseURL+'/logo.jpg'
	}

	if (path && hash) {
		//return "https://picsum.photos/200/300?id=" + Math.floor(Math.random() * 8);
		// const root = hasBaseUrl ? baseURL : "";
		// return root + path + hash + "_thumbnail.jpg";
		return baseURL + '/app/pan/image/thumbnail?hash='+item.hash+'&thumbnail=1&_token='+token.value
	}
	return baseURL + "/logo.jpg";
};

export const createImageUrl = function (item, hasBaseUrl = true) {
	const { path, hash, ext } = item;
	const root = hasBaseUrl ? baseURL : "";
	if (path && hash) {
		//return "https://picsum.photos/800?id=" + Math.floor(Math.random() * 8);
		//return root + path + hash + "." + ext;
		return (
			baseURL +
			"/app/pan/image/thumbnail?hash=" +
			item.hash +
			"&_token=" +
			token.value
		);
	}
};
